#include "app_runner.h"
#include "app_device.h"
#include "app_bt.h"
#include <unistd.h>
#include <signal.h>

static int is_running = 1;


void exit_handler(int signo) {
    is_running = 0;
}

int app_runner_run()
{
    // 注册信号处理函数
    signal(SIGINT, exit_handler);
    signal(SIGTERM, exit_handler);

    Device *device = app_device_init(SERIAL_FILE_PATH);
    app_bt_init(device);

    app_device_start();

    while(is_running) {
        sleep(1);
    }

    app_device_stop();
    return 0;
}